package com.chixing.fourteen.pojo;

import com.alipay.api.AlipayApiException;
import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import com.alipay.api.domain.AlipayAccount;
import com.alipay.api.request.AlipayTradePrecreateRequest;
import com.alipay.api.response.AlipayTradePrecreateResponse;

public class Test {
    public static void main(String[] args) throws AlipayApiException {
        AlipayClient alipayClient = new DefaultAlipayClient(
                "https://openapi.alipaydev.com/gateway.do",
                "2021000117667098",
                "MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQC1FuPiMjHVkarqgV7r2P233gtrHRcfhuwdKxQrjbRaiGjSYzyuiSnQ0zB4UygezVwiqGRxZ7ZFxEbHD5BiNAiHOwueEWtg4zVO09djnxcrnu9fAoSQZjIAHTwbVyhN2efaI+SkPfxVqP5Fqqw2a0w8xxWQ1EkIQmC1Fd9VL6hak9O1IMHsCHE96lDoYJtVp0ZGHu0hpcNrWMc348vvnKMEGQPz21TdK/UhUrMsq565ay84pDctuaF+bEwMQ0ZGDiFbh7IJr7gdvs05wAlct9VbJREyFm48avhJjnimYSgdjHDd8J8eKtPPVOuI561pFPrFHtL0Qf7C0ABQBuETJ34TAgMBAAECggEBAJT2TWLGU4QRHX1mCkUL7DmRp+bmuRywCg48X40sNc27JC7cfxA7uHAVKWvxS7F60G2aA3XeEGv3dxlMTkLZ9qH3CiluvtumSzWawTUrqw2w4ctP8OgviLXbVpRO79KKi1Q/7lbEvotgRjncmWjyfnYIdk76sVDf+Vk8ssgKOfy29pX0BMGZUH2EoYLVeMUa/m+vCeK6Q6Y/r0RNY9zO29LEXf+7GE4P8gRPOKT0kgVCLbC1Mb0jXNp6qX+STly7wlPjqgcPJsCiDDyp2xHA1HpMJHHRO5GpW7rRPR+Q7Ez7jEROY1CTpIGxrtTibYmEbDtXR38KbMajWM2W/Kp55mECgYEA5dAq2whlfXW/1Sd/SoyviQxBS93NVJTFz1rD0ynKI+fi6nd+u/X/NNb36zfWNLZ8T+oah7A587CxM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Y/cSmuW8qTI4w3CriC1e16gy1Wk9Ndbxi9v8f3O4nczWxVwt7G6UGGd9Kvfhq75f54OBwIHyoE7DBtFgMtnjXExJHhPwIOAoYu+zrwAV5VrPiTrVVNQdesMTLL17Vcrw3I7Rjv21nw1QIDAQAB",
                "RSA2");
        AlipayTradePrecreateRequest request = new AlipayTradePrecreateRequest();

        request.setBizContent("{" +
                "\"out_trade_no\":" + "\"20150320010101101\" ,"+
                "\"total_amount\":" + "\"8888.88\" ," +
                "\"subject\":" + "\"Java Is Good\"" +
                "}");
        AlipayTradePrecreateResponse response = alipayClient.execute(request);

        if(response.isSuccess()){
            System.out.println("调用成功");
        } else {
            System.out.println("调用失败");
        }

        String  form = alipayClient.pageExecute(request).getBody();
        System.out.println(form);
    }
}